<template>
	<view class='page'>
		<!-- 轮播图 -->
		<view class="swiper-container">
		  <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration" indicator-color='#FFFFFF' indicator-active-color='#E82239' class="swiper-content" circular='ture' @change="handleBannerSwiperChange">
		    <block v-for="(item,index) in goods.pic_list" v-key='index'>
		      <swiper-item>
		        <image :src="item.pic_url" class="slide-image" @tap="onGoodsImageClick"/>
		      </swiper-item>
		    </block>
		  </swiper>
		  <view class="dot-container">
		    <image :src="index==bannerCurrent?IMG_URL + 'swiper-dot2.png':IMG_URL + 'swiper-dot1.png'" v-for="(item,index) in imgUrls" wx:key='index' :class="index==bannerCurrent? 'selected-image': 'normal-image' "></image>
		  </view>
		</view>

		<!-- 商品信息 -->
		<view class="goods-detail">
			<view class="price-container flex-between">
				<view class="price-text">
					<text>￥</text>
					<text>{{goods.price}}</text>
				</view>
				<button class="share-btn flex-center" open-type='share' hover-class="button-hc" @tap='bomWxShare'>
					<image :src="IMG_URL+'share-icon.png'"></image>
					<text>分享</text>
				</button>
			</view>
			<view class="goods-name flex-between">
				<text>{{goods.name}}</text>
			</view>
		</view>

		<!-- 规格 -->
		<view class="goods-int flex-between" @tap="handleClickShowGuiGeModal" v-if="type==1">
			<text class="int-title">规格</text>
			<view class="int-text flex">
				<text>选择商品规格,参数</text>
				<image :src="IMG_URL+'yjt-icon3.png'"></image>
			</view>
		</view>

		<!-- 商品详情 -->
		<view class="goods-detail-title">{{type==1?'商品':'服务'}}详情</view>


		<!-- 导航栏 -->
		<view class="nav-container flex-center">
			<view class="nav-list" :class="navNum==1?'selected-nav':''" @tap="handleClickChangeNavNum" data-num="1">{{type==1?'商品':'服务'}}介绍</view>
		</view>

		<!-- 商品详情 -->
		<view class="goods-detail-content" v-if='navNum==1'>
			<!-- <template is="wxParse" :data="wxParseData:detail.nodes" /> -->
			<u-parse :content="goods.detail" @preview="preview" @navigate="navigate"></u-parse>
		</view>


		<!-- 用户评价列表 -->
		<!-- <view class="comment-container" wx:else>
		
			 <view class="comment-list" v-for="(item,index) in comment_list" v-for-item="comment" v-for-index="index">
				<image :src='comment.avatar_url' class="user-image"></image>
				<view class="list-content">
				  <view class="user-name flex-between">
					<view class="user-name-content nowrap">{{comment.nickname}}</view>
					<view class="user-star flex">
					  <image :src="IMG_URL+'star-icon.png'" v-for='(item,index) in comment.stars_attrs.length' wx:key='index'></image>
					  <image :src="IMG_URL+'star-icon1.png'" v-for='(item,index) in comment.has_stars_attrs.length' wx:key='index'></image>
					  <text>{{comment.score}}</text>
					</view>
				  </view>
				  <view class="comment-time">{{comment.addtime}}</view>
				  <view class="comment-content"> {{comment.content}}</view>
				  <scroll-view class="comment-scroll" scroll-x >
					<image @tap="commentPicView"  :data-index="index" :data-pic-index="pic_index" :src="pic_url" v-for="(item,index) in comment.pic_list}}" wx:for-index="pic_index" wx:for-item="pic_url" class="scroll-image" ></image>
				  </scroll-view>
				</view>
			  </view> -->
		<!-- 	</view> -->

		<!-- <no-data v-if="comment_list.length<=0"></no-data>
		  <no-data v-if="goods.detail.length<=0"></no-data> -->

		<view class="btn-container flex-end" v-if="type==1">
			<view class='ul_list flex'>
				<view class='li_list flex-center' @tap='goindex'>
					<view>
						<image src='/static/images/tabbar/index.png' mode="aspectFit"></image>
					</view>
					<view>首页</view>
				</view>
				<view class='li_list flex-center' open-type="contact" @tap="handleClickMakePhoneCall">
					<view>
						<image src='/static/images/tabbar/chat.png'></image>
					</view>
					<view>客服</view>
				</view>
				<navigator class='li_list flex-center' url="/pages/shop-cart/shop-cart">
					<view>
						<image src='/static/images/tabbar/peisong.png'></image>
					</view>
					<view>我的预算</view>
				</navigator>


				<navigator class='li_list flex-center' v-if="goods.order_gai>=1" style='margin-left:20rpx;' @tap='gokehu'>
					<view>
						<image src='/static/images/tabbar/peisong.png'></image>
					</view>
					<view>客户预算</view>
				</navigator>

			</view>
			<view class="comfirm-btn bg-style" hover-class="button-hc" @tap="handleClickShowGuiGe_add" :style="'background-image:url('+IMG_URL+'service-btn.png)'">加入预算</view>


			<view class="comfirm-btn-edit bg-style" hover-class="button-hc" @tap="handleClickShowGuiGe_add_gai" :style="'background-image:url('+IMG_URL+'service-btn1.png)'"
			 v-if="goods.order_gai>=1">加入修改预算</view>

		</view>



		<!-- 购物按钮 -->

		<!-- 购物按钮 -->
		<view class="btn-container flex-end" v-if="type==2">
			<view class="comfirm-btn bg-style" hover-class="button-hc" @tap="handleBack" :style="'background-image:url('+IMG_URL+'service-btn.png)'">门店</view>
			<view class="comfirm-btn bg-style" hover-class="button-hc" @tap="handleClickShowGuiGe_submit" :style="'background-image:url('+IMG_URL+'service-btn1.png)'">立即购买</view>
		</view>

		<!-- 规格弹窗-->




		<!-- <van-popup v-model="showGuiGe" @close="handleClickCloseGuiGeModal" position='bottom'> -->
		<view class='Popup' :hidden='!showGuiGe'>
			<view class="add-cart">
				<view class="add-detail flex-between">
					<view class="goods-image flex-center">
						<image :src='goods.attr_pic' mode="aspectFit" v-if="goods.attr_pic" :data-src="goods.attr_pic">
						</image>

						<image :src='goods.pic_list[0].pic_url' mode="aspectFit" v-else :data-src="goods.pic_list[0].pic_url">
						</image>

					</view>
					<view class="add-content">
						<view class="add-price">
							<text>￥</text>
							<text>{{goods.price}}</text>
						</view>
					</view>
					<image :src="IMG_URL+'exit-icon1.png'" class='exit-image' @tap="handleClickCloseGuiGeModal"></image>
				</view>
				<view class="guige-container" v-if="attr_group.attr_list.length>0" v-for="(attr_group,index) in attr_group_list"
				 v-for-item="attr_group">
					<view class="guige-title">{{attr_group.attr_group_name}}</view>
					<view class="guige-list">
						<text data-num="1" :class="item.checked?'selected-guige':''" v-for="(item,index) in attr_group.attr_list"
						 :data-id="item.attr_id" @tap="attrClick" :data-group-id="attr_group.attr_group_id">{{item.attr_name}}</text>
					</view>
				</view>
				<view class="add-num flex-between">
					<text>预算数量</text>
					<view class="buy-btn">
						<van-stepper v-model="form.number" integer :plus="numberAdd" :minus="numberSub" />
					</view>
				</view>
				<button class="submit-btn" @tap="handleClickToOrderSettlement" hover-class="button-pl">确定</button>
			</view>
		</view>
		<!-- </van-popup> -->

		<view class='mask' catchtouchmove="true" @click.stop='close' :hidden='!showGuiGe'></view>



	</view>






	</view>
</template>

<script>
	import uParse from '@/components/uParse/src/wxParse.vue'
	import app from '@/App.vue';
	var s = require("@/api.js"),
		a = getApp(),
		me = require("@/utils/method.js");
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js';
	var s = require("@/api.js");
	export default {
		data() {
			return {
				IMG_URL: 'http://try11.jiaodaoren.com/zhusiyao/zhenyangyou/',
				navNum: 1, //导航栏数字
				bannerCurrent: 0, //顶部轮播图指示点下标
				indicatorDots: false,
				autoplay: true,
				interval: 5000,
				duration: 1000,
				imgUrls: [
					'http://try11.jiaodaoren.com/zhusiyao/zhenyangyou/service-image.png',
					'http://try11.jiaodaoren.com/zhusiyao/zhenyangyou/service-image.png',
					'http://try11.jiaodaoren.com/zhusiyao/zhenyangyou/service-image.png',
				],

				showShareModal: false, //是否显示分享弹窗
				showPosterModal: false, //是否显示海报弹窗
				showGuiGe: false, //是否显示规格弹窗
				showCouponModal: false, //是否显示领取优惠券弹窗
				guigeNum: 1, //规格id

				maxQuantity: 10, //购买最大库存
				buyNum: 1, //当前购买数量

				/*渲染数据 */
				id: '',
				goods: [],
				attr_group_list: [], //商品规格
				form: {
					number: 1
				},
				carGoods: [],
				add_type: 1, //加入类型 1购物车 2立即购买
				goods_qrcode: '', //普通商品的海报
				visit_txt: '',
				/*评论继续渲染数据 */
				comment_list: [],
				hot_page: 1, //分页的条数
				type: 1,
				__user_info: '',
				userInfo: []
			}
		},
		components: {
			uParse
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			/*购物车 */
			var ia = this;
			if (options.type == 2) {
				ia.type = 2;
			}
			if (options.mch_id) {
				ia.mch_id = options.mch_id;
			}
			var da = 0,
				ra = 1,
				ea = !1,
				sa = !0;
			var na = options.quick;
			if (na) {
				var ca = uni.getStorageSync("item");
				if (ca) var _ = ca.total,
					ua = ca.carGoods;
				else var _ = {
						total_price: 0,
						total_num: 0
					},
					ua = [];

				ia.quick = na;
				ia.quick_list = ca.quick_list;
				ia.total = _;
				ia.carGoods = ua;
				ia.quick_hot_goods_lists = ca.quick_hot_goods_lists;
			}
			this.id = options.id;
			ia.getGoods();
		},
		methods: {
			//分享到微信
			bomWxShare:function(){
				var goods=this.goods;
				console.log('a分享的id',this.id);
				console.log('a分享的userId',this.userId);
				console.log('a分享的type',this.type);
				// #ifdef APP-PLUS
				let wx_id=this.main_config_wx_id;
				console.log('wx_id的值',wx_id);
				let imageUrl='/static/allAvatar.png';
				let title=goods.name;
				let path='pages/goods_detail/goods_detail?id='+goods.id;
				gyzjModel.prototype.shareLink(title,imageUrl,wx_id,path);
				// #endif
			},
			// 获取个人信息开始
			getUserInfo: function(token) {
				return new Promise((resolve, reject) => {
					model.getUserInfo((data) => {
						switch (data.code) {
							case 1:
								resolve(data);
								let userInfo = data.data.user;
								app.globalData.userInfo = userInfo;
								this.userInfo=userInfo;
								break;
							default:
								reject(data);
								uni.showToast({
									title: data.message,
									icon: 'none'
								})
								break;
						}
					}, (error) => {
						reject(error);
						console.log(error);
					}, token)
				})
			},
			/**获取个人信息结束 */
			goindex: function() {
				uni.switchTab({
					url: '/pages/index/index',
				})
			},
			//打电话
			handleClickMakePhoneCall(e) {
				let mobile = "13007489696";
				uni.makePhoneCall({
					phoneNumber: mobile,
				})
			},
			/*筛选公共方法 */
			handle_shuai_user() {
				var ea = this;
				uni.showNavigationBarLoading(), a.request({
					url: s.default.get_info,
					method: 'GET',
					success: function(s) {
						uni.hideNavigationBarLoading();
						/*处理显示倒计时时间 */
						if (0 == s.code) {
							ea.setData({
								user_info: s.data,
							})

						} else if (1 == s.code) {
							me.urlToast('加载失败', 0, 1000, 1);
						}

					}
				});
			},
			/*返回购物车 */
			handleBack: function() {
				var ea = this;
				let pages = getCurrentPages();
				let prevpage = pages[pages.length - 2];
				if (prevpage.route == 'pages/index_page/index_page' || prevpage.route == 'pages/gift_list/gift_list') {
					uni.navigateTo({
						url: '/pages/order_shop_list/order_shop_list?goods_id=' + ea.data.id,
					})
				} else {
					uni.navigateBack({
						delta: 1
					})
				}

			},
			/*调用详情,aa的参数不为0，则是展开分页 */
			getCommentList: function(aa) {
				var ia = this,
					new_attr_list = Array();
				aa && "active" != i.data.tab_comment || s && (a.request({
					url: s.default.comment_list,
					data: {
						goods_id: ia.id,
						page: ia.hot_page
					},
					success: function(ta) {
						console.log('ta的值', ta);
						if (0 == ta.code) {
							let attr_list = ta.data.list;
							for (var i = 0; i < attr_list.length; i++) {
								attr_list[i]['stars'] = parseInt(attr_list[i]['stars']);
								attr_list[i]['has_stars'] = parseInt(attr_list[i]['has_stars']);
								/*总长度添加数组 */
								me.number_attr(attr_list[i], 'stars');
								me.number_attr(attr_list[i], 'has_stars');
								/*总长度添加数组 */
							}
							(ia.setData({
								comment_count: ta.data.comment_count,
								comment_list: aa ? ia.comment_list.concat(attr_list) : attr_list
							}));

						}

					}
				}));
			},
			get_attr: function(attr, key) {
				for (var iaa = 0; iaa < attr[key]; iaa++) {
					attr[key + '_attrs'].push(0);
				}(iaa);
			},
			/*放大图片 */
			commentPicView: function(t) {
				var aa = this,
					o = t.currentTarget.dataset.index,
					i = t.currentTarget.dataset.picIndex;
				uni.previewImage({
					current: aa.data.comment_list[o].pic_list[i],
					urls: aa.data.comment_list[o].pic_list
				});
			},
			/*标品图片查看 */
			onGoodsImageClick: function(t) {
				var a = this,
					o = [],
					i = t.currentTarget.dataset.index;
				for (var r in a.data.goods.pic_list) o.push(a.data.goods.pic_list[r].pic_url);
				uni.previewImage({
					urls: o,
					current: o[i]
				});
			},
			/*调用商品详情 */
			getGoods() {
				/*商品详情 */
				var e = this,that=this;
				uni.showNavigationBarLoading(), uni.request({
					url: s.default.goods,
					data: {
						id: this.id
					},
					method: 'GET',
					success: function(s) {
						var o = s.data.detail;

						// i.wxParse('article', 'html', article, that, 5);
						// i.wxParse("detail", "html", o, e);
						//根据店铺动态设置头部文字
						uni.setNavigationBarTitle({
							title: s.data.name,
						})
						uni.hideNavigationBarLoading();
						s = s.data;
						console.log('s的值',s);
						if (0 == s.code) {
							console.log('s.data的值',s.data);
							that.goods = s.data;
								that.attr_group_list = s.data.attr_group_list;
						}
					}
				});
			},

			/*商品属性修改 */
			attrClick: function(come) {
				var ia = this,
					ra = come.target.dataset.groupId,
					ea = come.target.dataset.id,
					sa = ia.attr_group_list;
				for (var da in sa)
					if (sa[da].attr_group_id == ra)
						for (var na in sa[da].attr_list) sa[da].attr_list[na].attr_id == ea ? sa[da].attr_list[na].checked = !0 : sa[da]
							.attr_list[na].checked = !1;
				ia.attr_group_list= sa;
				var ca = [],
					_ = !0;
				for (var da in sa) {
					var ua = !1;
					for (var na in sa[da].attr_list)
						if (sa[da].attr_list[na].checked) {
							ca.push(sa[da].attr_list[na].attr_id), ua = !0;
							break;
						}
					if (!ua) {
						_ = !1;
						break;
					}
				}
				var la = ia.carGoods;
				if (la) {
					for (var ga = la.length, ma = [], da = 0; da < ga; da++) {
						if (la[da].goods_id == ia.goods.id) var fa = la[da].attr;
						if (fa) {
							for (var pa = fa.length, ma = [], ha = 0; ha < pa; ha++) ma.push(fa[ha].attr_id);
							va = 0;
							if (ca.join(",") == ma.join(",")) {
								va = la[da].num;
								break;
							}
						} else var va = 0;
					}
					ia.check_num=va || null;
				}
				_ && uni.request({
					url: s.default.goods_attr_info,
					data: {
						goods_id: ia.goods.id,
						attr_list: JSON.stringify(ca)
					},
					success: function(ta) {
						if (0 == ta.code) {
							var aa = ia.goods;
							aa.price = ta.data.price, aa.num = ta.data.num, aa.attr_pic = ta.data.pic, ia.goods=aa;
								ia.miaosha_data= ta.data.miaosha;
						}
					}
				});
			},
			/*添加数量 */
			numberSub: function() {
				var ta = this,
					aa = ta.data.form.number;
				if (aa <= 1) return !0;
				aa--, ta.setData({
					form: {
						number: aa
					}
				});
			},
			numberAdd: function() {
				var ta = this,
					aa = ta.data.form.number;
				aa++, ta.setData({
					form: {
						number: aa
					}
				});
			},
			numberBlur: function(ta) {
				var aa = this,
					oa = ta.detail.value;
				oa = parseInt(oa), isNaN(oa) && (oa = 1), oa <= 0 && (oa = 1), aa.setData({
					form: {
						number: oa
					}
				});
			},

			/*移除收藏 */
			favoriteRemove: function() {
				var e = this;
				let mch_id = this.data.goods.mch_id;
				a.request({
					url: s.user.favorite_remove,
					method: "post",
					data: {
						goods_id: e.data.goods.id,
						type: 1,
						mch_id
					},
					success: function(t) {
						if (0 == t.code) {
							me.urlToast('取消收藏成功!');
							var o = e.data.goods;
							o.mchCount = 0, e.setData({
								goods: o
							});
						}
					}
				});
			},
			//添加收藏
			favoriteAdd: function() {
				var e = this;
				let mch_id = this.data.goods.mch_id;
				a.request({
					url: s.user.favorite_add,
					method: "post",
					data: {
						goods_id: e.data.goods.id,
						type: 1,
						mch_id
					},
					success: function(t) {
						if (0 == t.code) {
							me.urlToast('添加收藏成功!');
							var o = e.data.goods;
							o.mchCount = 1, e.setData({
								goods: o
							});
						}
					}
				});
			},
			//保存图片至相册
			handleClickSaveGoodsImage() {
				let self = this
				uni.downloadFile({
					// url: this.data.IMG_URL + "poster-image.png",
					url: self.data.goods_qrcode || this.data.IMG_URL + "poster-image.png",
					success: function(res) {
						console.log('保存图片成功进来', res);
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success(result) {
								console.log('保存成功', result);
								uni.showToast({
									title: '保存成功',
									icon: 'success',
									duration: 1000
								})
								setTimeout(() => {
									self.setData({
										showPosterModal: false
									})
								}, 1000)
								clearTimeout()
							},
							fail() {
								console.log('保存图片失败进来');
								uni.getSetting({
									success: function(res) {
										var statu = res.authSetting;
										if (!statu['scope.writePhotosAlbum']) {
											uni.showModal({
												title: '是否授权获取相册权限',
												content: '需要获取您的相册权限，请确认授权，否则无法保存图片至相册',
												success: function(tip) {
													if (tip.confirm) {
														uni.openSetting({
															success: function(data) {
																console.log(11)
																if (data.authSetting["scope.writePhotosAlbum"] === true) {
																	uni.showToast({
																		title: '授权成功',
																		icon: 'success',
																		duration: 1000
																	})
																	self.handleClickSaveGoodsImage()
																} else {
																	uni.showToast({
																		title: '授权失败',
																		icon: 'none',
																		duration: 1000
																	})
																}
															}
														})
													}
												}
											})
										}
									},
									fail: function(res) {
										uni.showToast({
											title: '调用授权窗口失败',
											icon: 'none',
											duration: 1000
										})
									}
								})
							}
						})
					}
				})
			},

			//关闭分享弹窗
			handleClickCloseShareModal() {
				this.setData({
					showShareModal: false,
					haibaoBg: '',
				});
			},
			//打开分享弹窗 生成海报
			handleClickShowShareModal() {
				// pages/goods_detail/goods_detail
				let page_url = 'pages/goods_detail/goods_detail';
				console.log('1打开分享');
				//分享海报
				let that = this;

				a.request({
					url: s.default.goods_qrcode,
					data: {
						goods_id: this.data.goods.id, //商品id号码
						page_url,
					},
					success: function(aa) {
						console.log('生成的图片', aa);
						0 == aa.code && that.setData({
							goods_qrcode: aa.data.pic_url
						}), 1 == a.code;
						/*打开弹幕，并且显示1 */
						that.setData({
							// showShareModal: true,
							showPosterModal: true,
							haibaoBg: 1,
						});
					}
				});
			},
			/*放大图片 */
			goodsQrcodeClick: function(t) {
				var a = t.currentTarget.dataset.src;
				uni.previewImage({
					urls: [a]
				});
			},
			//显示规格购买弹窗  加入购物车
			handleClickShowGuiGe_add() {
				this.showGuiGe = true;
				this.add_type = 1;
			},


			//显示规格购买弹窗  加入购物车
			handleClickShowGuiGe_add_gai() {
				this.showGuiGe = true;
				this.add_type = 3;
			},

			//显示规格购买弹窗   立即购买表单提交
			handleClickShowGuiGe_submit() {
				if (this.data.type == 1) {
					this.showGuiGe = true;
					this.add_type = 2;
				} else {


					/*立即报名提交订单 */
					var e = this, 
						goods_info = {
							"goods_id": this.data.id,
							"attr": [{
								"attr_group_id": 1,
								"attr_group_name": "规格",
								"attr_id": 1,
								"attr_name": "默认"
							}],
							"num": 1,
							"mch_id": this.data.mch_id
						};
					goods_info = JSON.stringify(goods_info);
					if (e.data.mch_id) {
						uni.navigateTo({
							url: '/pages/service_order_settlement/service_order_settlement?goods_info=' + goods_info,
						})
					} else {
						uni.navigateTo({
							url: '/pages/order_shop_list/order_shop_list?goods_id=' + e.data.id,
						})
					}

				}

			},
			/**
			 * 用户点击右上角分享
			 */
			onShareAppMessage: function() {
				//console.log('global目前的值', app.globalData.userInfo);
				// var user_info = this.data.user_info, self = this, t = this, aa = uni.getStorageSync("user_info");
				var user_info = app.globalData.userInfo,
					self = this;
				console.log('user_info的值', user_info);
				if (this.data.type == 1) {
					// if (user_info.level >= 1) {
					return {
						title: user_info.nickName + ":向你推荐了一个装修材料",
						path: '/pages/goods_detail/goods_detail?id=' + self.data.id + '&user_id=' + user_info.id
					}
					// } else {
					//   return {
					//     title: user_info.nickname + ":向你推荐了一个商品",
					//     path: '/pages/goods_detail/goods_detail?id=' + self.data.id
					//   }
					// }

				} else if (this.data.type == 2) {
					if (user_info.level >= 1) {
						return {
							title: user_info.nickname + ":向你推荐了一个服务",
							path: '/pages/goods_detail/goods_detail?id=' + self.data.id + '&type=2&user_id=' + user_info.id
						}
					} else {
						return {
							title: user_info.nickname + ":向你推荐了一个服务",
							path: '/pages/goods_detail/goods_detail?id=' + self.data.id + '&type=2'
						}
					}
				}
				this.setData({
					// showShareModal: false,
					showPosterModal: false,
				});

			},
			//跳转到订单结算页
			handleClickToOrderSettlement() {
				//新的处理订单的逻辑
				var ia = this;
				if (ia.add_type == 2) {
					this.submit("BUY_NOW");
					//立即购买的逻辑
				} else if (ia.add_type == 1) {
					console.log('加入1购物车');
					this.submit("ADD_CART");
				} else if (ia.add_type == 3) {
					console.log('加入3购物车');
					this.submit("ADD_CART_GAI");
				}
			},
			//submit提交方式
			submit: function(aa) { 
				var arr = this.main_getGlobal(); 
				var ia = this;
				var help_order_id = uni.getStorageSync('help_order_id');
				if (!ia.showGuiGe) return ia.setData({
					showGuiGe: !0
				}), !0;
				if (ia.form.number > ia.goods.num) return uni.showToast({
					icon: 'none',
					title: "商品库存不足，请选择其它规格或数量",
				}), !0;
				var ra = ia.attr_group_list,
					ea = [];
				for (var sa in ra) {
					var da = !1;
					for (var na in ra[sa].attr_list)
						if (ra[sa].attr_list[na].checked) {
							da = {
								attr_id: ra[sa].attr_list[na].attr_id,
								attr_name: ra[sa].attr_list[na].attr_name
							};
							break;
						}
					if (!da) return uni.showToast({
						title: "请选择" + ra[sa].attr_group_name,
						icon: 'none',
						// showGuiGe: false,
					}), !0;
					ea.push({
						attr_group_id: ra[sa].attr_group_id,
						attr_group_name: ra[sa].attr_group_name,
						attr_id: da.attr_id,
						attr_name: da.attr_name
					});
				}
				"ADD_CART" == aa && (uni.showLoading({
						title: "正在提交",
						mask: !0
					}), uni.request({
						url: s.cart.add_cart,
						method: "POST",
						data: {
							goods_id: ia.id,
							attr: JSON.stringify(ea),
							num: ia.form.number,
							mobile:arr.token,
							type:arr.type
						},
						success: function(ta) {
							uni.hideLoading(), uni.showToast({
								title: ta.msg,
								duration: 1500
							}), ia.setData({
								show_attr_picker: !1,
								showGuiGe: false
							});
						}
					})),
					"ADD_CART_GAI" == aa && (uni.showLoading({
						title: "正在提交",
						mask: !0
					}), a.request({
						url: s.cart.add_cart_edit,
						method: "POST",
						data: {
							goods_id: ia.id,
							attr: JSON.stringify(ea),
							num: ia.form.number,
							help_order_id,
						},
						success: function(ta) {
							uni.hideLoading(), uni.showToast({
								title: ta.msg,
								duration: 1500
							}), ia.setData({
								show_attr_picker: !1,
								showGuiGe: false
							});
						}
					})),
					"BUY_NOW" == aa && (ia.setData({
							show_attr_picker: !1
						}),
						// console.log(JSON.stringify({
						//   goods_id: ia.id,
						//   attr: ea,
						//   num: ia.form.number
						// }))

						uni.redirectTo({
							url: "/pages/order_settlement/order_settlement?goods_info=" + JSON.stringify({
								goods_id: ia.id,
								attr: ea,
								num: ia.form.number
							})
						})

					);
			},
			//领取优惠券
			receive: function(n) {
				var e = this,
					i = n.currentTarget.dataset.id,
					index, index = n.currentTarget.dataset.index,
					coupon_list = e.data.goods;
				uni.showLoading({
					mask: !0
				}), e.hideGetCoupon || (e.hideGetCoupon = function(t) {
					var o = t.currentTarget.dataset.url || !1;
					e.setData({
						get_coupon_list: null
					}), o && uni.navigateTo({
						url: o
					});
				}), a.request({
					url: s.coupon.receive,
					data: {
						id: i
					},
					success: function(t) {
						if (t.code == 0) {
							uni.showToast({
								title: '恭喜你，领到了',
								icon: 'none',
								mask: true,
								duration: 1500
							})
							coupon_list['sendCouponList'][index].is_receive = 1;
							e.setData({
								goods: coupon_list
							})
						} else {
							me.urlToast(t.msg, '', 1000);
						}

						// 0 == t.code && e.setData({
						//   get_coupon_list: t.data.list,
						//   coupon_list: t.data.coupon_list
						// });
					},
					complete: function() {
						uni.hideLoading();
					}
				});
			},


			/*****************前端所需参数****/
			//领取优惠券
			handleClickGetCoupon(e) {
				uni.showToast({
					title: '恭喜你，领到了',
					icon: 'none',
					mask: true,
					duration: 1500
				})
			},

			// 监听顶部轮播图切换事件，改变下标
			handleBannerSwiperChange(e) {
				this.setData({
					bannerCurrent: e.detail.current
				})
			},

			//改变导航栏数字
			handleClickChangeNavNum(e) {
				let navNum = e.currentTarget.dataset.num
				this.setData({
					navNum: navNum
				})
			},

			//显示领取优惠券弹窗
			handleClickShowCouponModal() {
				let coupon_list = this.data.goods.sendCouponList;
				if (coupon_list.length <= 0) {

				} else {
					this.setData({
						showCouponModal: true
					})
				}

			},

			//关闭领取优惠券弹窗
			handleClickCloseCouponModal() {
				this.showCouponModal=false;
			},

			//显示分享海报弹窗
			handleClickShowPosterModal() {
				this.setData({
					showPosterModal: true
				})
			},



			//关闭分享海报弹窗
			handleClickClosePosterModal() {
				this.setData({
					showPosterModal: false
				})
			},

			//显示规格购买弹窗
			handleClickShowGuiGeModal() {
				this.showGuiGe = true;
			},

			//关闭规格购买弹窗
			handleClickCloseGuiGeModal() {
				this.showGuiGe=false;
			},
			//改变规格Num
			handleClickChangeGuigeNum(e) {
				this.guigeNum=e.currentTarget.dataset.num;
			},



			/**
			 * 用户点击右上角分享
			 */
			// onShareAppMessage: function() {
			//   this.setData({
			//     showPosterModal: false,
			//   });
			// },

			//放大图片
			handleClickPreviewImage(e) {
				uni.previewImage({
					current: this.data.IMG_URL + 'com-list1.png', // 当前显示图片的http链接
					urls: [this.data.IMG_URL + 'com-list1.png', this.data.IMG_URL + 'com-list2.png', this.data.IMG_URL +
						'com-list3.png'
					] // 需要预览的图片http链接列表
				})
			},

			handleClickToIndexPage() {
				uni.reLaunch({
					url: '/pages/index_page/index_page',
				})
			},

			//跳转到订单结算页面
			handleClickToOrderSettlementPage() {
				uni.navigateTo({
					url: '/pages/order_settlement/order_settlement',
				})
			}
		}
	}
</script>

<style>
	/* pages/goods_detail/goods_detail.wxss */
	@import url("@/components/uParse/src/wxParse.css");

	page {
		padding-bottom: 100upx;
	}

	/* 轮播图 */

	.swiper-container {
		position: relative;
	}

	.swiper-content {
		height: 450upx;
	}

	.slide-image {
		width: 100%;
		height: 100%;
	}

	.dot-container {
		position: absolute;
		bottom: 20upx;
		display: flex;
		align-items: center;
		left: 50%;
		transform: translateX(-50%);
	}

	.dot-container image {
		margin-right: 10upx;
	}

	.dot-container .selected-image {
		width: 12upx;
		height: 6upx;
		display: block;
	}

	.dot-container .normal-image {
		width: 12upx;
		height: 6upx;
	}

	.dot-container image:nth-last-of-type(1) {
		margin: 0;
	}

	/* 商品信息 */

	.goods-detail {
		padding: 30upx 28upx;
		border-bottom: #f5f5f5 16upx solid;
	}

	.share-btn {
		width: 100upx;
		height: 40upx;
		background: linear-gradient(135deg, rgba(255, 81, 51, 1), rgba(248, 40, 37, 1));
		box-shadow: 0px 3upx 9upx 0px rgba(248, 37, 40, 0.35);
		border-radius: 20upx;
		padding: 0;
		margin: 0;
	}

	.share-btn image {
		width: 18upx;
		height: 19upx;
		margin-right: 6upx;
	}

	.share-btn text {
		font-size: 22upx;
		color: rgba(255, 255, 255, 1);
	}

	.price-text text:nth-of-type(1) {
		color: #ec1c24;
		font-size: 26upx;
	}

	.price-text text:nth-of-type(2) {
		color: #ec1c24;
		font-weight: 500;
		font-size: 40upx;
	}

	.price-text text:nth-of-type(3) {
		color: rgba(153, 153, 153, 1);
		margin-left: 10upx;
		font-size: 20upx;
		text-decoration: line-through;
	}

	.goods-name {
		padding-top: 30upx;
	}

	.goods-name text:nth-of-type(1) {
		font-size: 30upx;
		font-weight: bold;
		color: rgba(51, 51, 51, 1);
		display: inline-block;
		flex: 1;
		padding-right: 30upx;
	}

	.goods-name text:nth-of-type(2) {
		font-size: 28upx;
		color: rgba(153, 153, 153, 1);
	}

	.goods-tips {
		height: 28upx;
		border: 1upx solid rgba(236, 28, 36, 1);
		border-radius: 14upx;
		line-height: 26upx;
		padding: 0 12upx;
		font-size: 20upx;
		color: rgba(236, 28, 36, 1);
		margin-top: 14upx;
		display: inline-block;
	}

	/* 优惠券 */

	.goods-int {
		padding: 0 28upx;
		height: 100upx;
	}

	.int-title {
		font-size: 30upx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.int-text text {
		font-size: 26upx;
		color: rgba(153, 153, 153, 1);
	}

	.int-text image {
		width: 12upx;
		height: 19upx;
		margin-left: 12upx;
	}

	.border-bottom {
		border-bottom: 1upx solid #f5f5f5;
	}

	.int-text .color-red {
		color: rgba(236, 28, 36, 1);
	}

	/* 商品详情 */

	.goods-detail-title {
		padding: 30upx 28upx;
		font-size: 30upx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	/* 导航栏 */

	.goods-detail-title {
		border-top: #f5f5f5 16upx solid;
	}

	.nav-container {
		height: 64upx;
		margin: 0 auto 26upx;
	}

	.nav-list {
		padding: 0 20upx;
		min-width: 190upx;
		text-align: center;
		line-height: 64upx;
		font-size: 26upx;
		color: rgba(51, 51, 51, 1);
		border-top: 1upx solid #ddd;
		border-bottom: 1upx solid #ddd;
	}

	.nav-list:nth-of-type(1) {
		border-radius: 6upx 0 0 6upx;
		border-left: 1upx solid #ddd;
	}

	.nav-list:nth-of-type(2) {
		border-radius: 0 6upx 6upx 0;
		border-right: 1upx solid #ddd;
	}

	.nav-container .selected-nav {
		border: 1upx solid rgba(236, 28, 36, 1);
		color: rgba(236, 28, 36, 1);
	}

	.goods-detail-content image {
		display: block;
	}

	/* 用户评价列表 */

	.comment-container {
		background: #fff;
	}

	.comment-list {
		display: flex;
		justify-content: space-between;
		padding: 28upx;
		border-bottom: 16upx solid #f5f5f5;
	}

	.user-image {
		width: 74upx;
		height: 74upx;
		border-radius: 50%;
	}

	.list-content {
		flex: 1;
		padding-left: 20upx;
	}

	.user-name-content {
		font-size: 30upx;
		color: rgba(1, 1, 1, 1);
		max-width: 350upx;
	}

	.user-star text {
		font-size: 20upx;
		color: rgba(236, 28, 36, 1);
	}

	.user-star image {
		width: 18upx;
		height: 18upx;
		margin-right: 8upx;
	}

	.comment-time {
		padding: 10upx 0 30upx;
		color: rgba(153, 153, 153, 1);
	}

	.comment-content {
		color: rgba(51, 51, 51, 1);
		line-height: 40upx;
	}

	.comment-scroll {
		width: 600upx;
		display: flex;
		white-space: nowrap;
		margin: 28upx 0;
	}

	.scroll-image {
		margin-right: 6upx;
		width: 196upx;
		height: 166upx;
		border-radius: 10upx;
	}

	.comment-btn button {
		width: 190upx;
		height: 70upx;
		background: rgba(246, 246, 246, 1);
		border-radius: 35upx;
		margin: 0;
		padding: 0;
		line-height: 70upx;
		font-size: 28upx;
		color: rgba(153, 153, 153, 1);
	}

	.comment-all-btn {
		width: 190upx;
		height: 56upx;
		border: 1upx solid rgba(221, 221, 221, 1);
		border-radius: 28upx;
		text-align: center;
		line-height: 54upx;
		color: rgba(153, 153, 153, 1);
		margin: 40upx auto;
		font-size: 24upx;
		padding: 0;
	}

	/* 购物按钮 */

	.btn-container {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		height: 100upx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0px -3upx 7upx 0px rgba(212, 212, 212, 0.2);
		/* padding-right: 28upx; */
		/*修改*/
		padding-right: 108upx;
	}

	.comfirm-btn,
	.comfirm-btn-edit {
		line-height: 80upx;
		font-size: 26upx;
		color: rgba(255, 255, 255, 1);
		text-align: center;
		width: 190upx;
		height: 80upx;
		/*修改*/
		margin-left: auto;
	}

	.comfirm-btn-edit {
		width: 240upx;
	}

	/* 规格弹窗-- */

	.van-popup {
		background: rgba(0, 0, 0, 0) !important;
	}

	.add-cart {
		background: rgba(255, 255, 255, 1);
		border-radius: 20upx 20upx 0px 0px;
		padding: 0 28upx 44upx;
	}

	.goods-image {
		width: 240upx;
		height: 200upx;
		border-radius: 10upx;
	}

	.goods-image image {
		max-height: 100%;
	}

	.add-content {
		flex: 1;
		padding-left: 32upx;
		display: flex;
		flex-direction: column;
	}

	.add-price {
		margin-bottom: 30upx;
	}

	.add-price text:nth-of-type(1) {
		color: rgba(255, 59, 50, 1);
		font-size: 24upx;
	}

	.add-price text:nth-of-type(2) {
		color: rgba(255, 59, 50, 1);
		font-size: 32upx;
		font-weight: 500;
	}

	.add-content view:nth-of-type(2) {
		color: rgba(153, 153, 153, 1);
	}

	.add-detail {
		position: relative;
		padding: 25upx 0;
	}

	.exit-image {
		width: 44upx;
		height: 44upx;
	}

	.add-detail .exit-image {
		position: absolute;
		right: 0;
		top: 25upx;
	}

	.guige-container {
		padding: 35upx 0;
		border-bottom: 1upx solid #f6f6f6;
	}

	.guige-title { 
		font-size: 28upx;
		color: rgba(51, 51, 51, 1);
		text-align:left;
	}

	.guige-list {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.guige-list text {
		background: rgba(240, 240, 240, 1);
		border-radius: 6upx;
		display: inline-block;
		margin-right: 35upx;
		padding: 10upx 25upx;
		font-size: 26upx;
		color: #666;
		margin-top: 25upx;
	}

	.guige-list .selected-guige {
		background: rgba(229, 68, 0, 0.1);
		border: 1upx solid rgba(229, 68, 0, 1);
		border-radius: 6upx;
		color: #e54400;
	}

	.add-num {
		padding: 35upx 0;
		border-bottom: 1upx solid #f6f6f6;
	}

	.add-num>text {
		font-size: 28upx;
		color: rgba(51, 51, 51, 1);
	}

	.submit-btn {
		width: 694upx;
		height: 90upx;
		background: linear-gradient(135deg, rgba(255, 81, 51, 1), rgba(248, 40, 37, 1));
		box-shadow: 0px 3upx 9upx 0px rgba(248, 37, 40, 0.35);
		border-radius: 42upx;
		line-height: 90upx;
		padding: 0;
		border: none;
		font-size: 30upx;
		color: rgba(254, 254, 254, 1);
		margin: 38upx auto 0;
	}

	.reduce-btn {
		width: 64upx !important;
		height: 32upx !important;
		line-height: 32upx !important;
		background: rgba(255, 255, 255, 0) !important;
		font-size: 32upx !important;
		color: #848484 !important;
		background: #fff !important;
		box-sizing: border-box !important;
		margin: 0 !important;
	}

	.van-stepper__minus--disabled {
		color: rgb(185, 185, 185) !important;
	}

	.add-btn {
		width: 64upx !important;
		height: 32upx !important;
		line-height: 32upx !important;
		background: rgba(255, 255, 255, 0) !important;
		font-size: 32upx !important;
		color: #848484 !important;
		box-sizing: border-box !important;
		margin: 0 !important;
	}

	.van-stepper__plus--disabled {
		color: #ccc !important;
	}

	.num-text {
		width: 64upx !important;
		height: 32upx !important;
		line-height: 32upx !important;
		background: #f6f7f8 !important;
		color: rgba(51, 51, 51, 1) !important;
		font-size: 26upx !important;
		padding: 0 2upx !important;
	}

	/* 优惠券弹窗 */

	.coupon-container {
		background: rgba(255, 255, 255, 1);
		border-radius: 20upx 20upx 0px 0px;
		padding: 0 28upx 100upx;
	}

	.coupon-content-title {
		padding: 40upx 0;
	}

	.coupon-content-title text {
		font-size: 34upx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.coupon-scroll {
		max-height: 700upx;
	}

	.coupon-list {
		height: 160upx;
		background: rgba(249, 249, 249, 1);
		border-radius: 2upx;
		overflow: hidden;
		margin-bottom: 16upx;
	}

	.coupon-num {
		width: 226upx;
		align-items: center;
		border-right: 1upx dashed #cdcdcd;
		height: 100%;
	}

	.coupon-price text:nth-of-type(1) {
		font-size: 36upx;
		color: #ff4b4b;
	}

	.coupon-price text:nth-of-type(2) {
		font-size: 70upx;
		color: #ff4b4b;
	}

	.coupon-tips {
		font-weight: 500;
		color: rgba(153, 153, 153, 1);
		margin-top: 4upx;
		max-width: 200upx;
	}

	.coupon-detail {
		flex: 1;
		height: 100%;
		padding: 0 30upx;
	}

	.coupon-title-label {
		height: 26upx;
		background: rgba(255, 75, 75, 1);
		border-radius: 4upx;
		padding: 0 4upx;
		line-height: 26upx;
		font-size: 18upx;
		color: rgba(255, 255, 255, 1);
	}

	.coupon-title-text {
		font-size: 30upx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		margin-left: 14upx;
	}

	.coupon-time {
		color: rgba(153, 153, 153, 1);
		margin-top: 20upx;
	}

	.coupon-btn {
		align-items: center;
		width: 136upx;
		height: 100%;
	}

	.coupon-btn text {
		font-size: 28upx;
		font-weight: 500;
		color: rgba(255, 255, 255, 1);
	}

	.get-succ text {
		font-size: 28upx;
		font-weight: 500;
		color: rgba(255, 75, 75, 1);
	}

	/* 海报弹窗 */

	.poster-container {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
	}

	.poster-content {
		position: absolute;
		left: 50%;
		bottom: 234upx;
		transform: translateX(-50%);
		width: 564upx;
		height: 800upx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0px 4upx 32upx 0px rgba(113, 113, 113, 0.29);
		z-index: 2;
	}

	.poster-image {
		width: 100%;
		height: 100%;
		display: block;
	}

	.poster-exit-image {
		width: 51upx;
		height: 51upx;
		position: absolute;
		right: -56upx;
		top: -56upx;
		border-radius: 50%;
	}

	.poster-share {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 300upx;
		background: rgba(240, 240, 240, 1);
		display: flex;
		align-items: flex-end;
		justify-content: center;
	}

	.poster-btn {
		align-items: center;
		width: 170upx;
		height: 170upx;
		margin: 0;
		padding: 0;
		margin-bottom: 30upx;
		background: rgba(0, 0, 0, 0)
	}

	.poster-btn:nth-of-type(1) {
		margin-right: 40upx;
	}

	.poster-btn image {
		width: 92upx;
		height: 94upx;
		margin-bottom: 16upx;
	}

	.poster-btn text {
		font-size: 26upx;
		color: rgba(102, 102, 102, 1);
		line-height: 26upx;
	}

	/*自己设置样式*/
	page {
		background-color: white;
	}

	.bg-style {
		background-size: 100% 100%;
		background-repeat: no-repeat;
		background-position: left top;
	}

	.flex-start {
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}

	.flex-between {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.flex-center {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.flex-end {
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.ul_list {
		/* width:300upx; */
		width: 420upx;
		height: 80upx;
	}

	.ul_list .li_list {
		/* width:30%; */
		width: 25%;
		height: 100%;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		position: relative;
	}

	.ul_list .li_list:nth-of-type(1) {
		width: 80upx;
	}

	.ul_list .li_list:nth-of-type(2) {
		width: 80upx;
	}

	.ul_list .li_list:nth-of-type(3) {
		width: 100upx;
	}

	.ul_list .li_list:nth-of-type(4) {
		width: 120upx;
	}

	.li_list view:nth-of-type(1) image,
	.li_list view:nth-of-type(1) {
		width: 40upx;
		height: 40upx;

	}

	.li_list view:nth-of-type(2) {
		font-size: 20upx;
	}

	.hidden_btn {
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: 999;
	}

	.flex-end {
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.Popup {
		width: 750rpx;
		background-color: #EDE8EE;
		position: fixed;
		bottom: -380rpx;
		left: 0rpx;
		/* margin-left: -280rpx; */
		transform: translateY(-50%);
		z-index: 320;
		border-radius: 5px;
		// border-top:1rpx solid #fff;
		text-align: center;
	}

	.Popup .Popup_image {
		width: 100%;
		height: 100%;
	}

	/* .Popup image {
		// width: 100%;
		width: 300rpx;
		height: 300rpx;
		border-radius: 50%;
		border-top-left-radius: 5px;
		border-top-right-radius: 5px;
		margin-top: 32rpx;
	} */

	/* .Popup image{width:150rpx;height:150rpx;margin:-67rpx auto 0 auto;display:block;border: 8rpx solid #fff;border-radius: 50%} */
	.Popup .title {
		font-size: 28rpx;
		color: #000;
		text-align: center;
		margin-top: 30rpx
	}

	.Popup .tip {
		font-size: 22rpx;
		color: #555;
		padding: 0 24rpx;
		margin-top: 25rpx;
		margin-left: 5rpx;
	}

	.Popup .tip_huang {
		font-size: 25rpx;
		color: #555;
		padding: 0 24rpx;
		margin-top: 25rpx;
		color: #D54202;
	}


	.Popup .bottom .item {
		width: auto;
		height: 80rpx;
		background-color: #eeeeee;
		text-align: center;
		line-height: 80rpx;
		font-size: 24rpx;
		color: #666;
		margin-top: 28rpx;
	}

	.Popup .bottom .item.on {
		width: 100%
	}

	.flex {
		display: flex;
	}

	.Popup .bottom .item.grant {
		background: linear-gradient(135deg, rgba(255, 130, 52, 1), rgba(255, 60, 29, 1));
		font-size: 28rpx;
		color: #fff;
		font-weight: bold;
		background-color: #e93323;
		border-radius: 70rpx;
		padding: 0rpx 50rpx;
	}

	.mask {
		position: fixed;
		top: 0;
		right: 0;
		left: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.99);
		z-index: 310;
	}
</style>
